﻿<%@ Page Title="POSSystem | Contracts" Theme="POSSystem" Language="C#" MasterPageFile="~/Application.Master"
    AutoEventWireup="true" CodeBehind="Contract.aspx.cs" Inherits="WebUI.Contract" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<%@ Register Src="~/Controls/POSControls/AddContractCtrl.ascx" TagName="AddContract"
    TagPrefix="uc" %>
<%@ Register Src="~/Controls/SysControls/PageHeader.ascx" TagPrefix="uc" TagName="PageHeader" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ApplicationHeadHolder" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ApplicationContentHolder" runat="server">

    <script type="text/javascript">
        var IMEILength = <%= WebUI.BasePage.SysVars.IMEILength %>;
        
         function isNumeric(value) {
            if (value != null && !value.toString().match(/^[-]?\d*\.?\d*$/)) return false;
                return true;
         }
        function txtIMEI_onchange(txt) {
            if(!isNumeric(txt.value)){
                alert("Invalid IMEI number!");
                txt.value = "";
                return;
            }
            
            if(txt.value.length >= IMEILength){
                document.getElementById("<%=btnAddIMEI.ClientID %>").click();
                txt.value='';
            }
        }       
        
        function onRemoveContract(){
            var id = getSelectedItemID<%=addContract.ClientID %>();
            if(id == null){
                alert("No item was selected!");
                return false;
            }
            
            return confirm("Delete a category will affect all related products. Do you want to continue?");
        }
        
        function onAddService() {
            var id = getSelectedItemID<%=addContract.ClientID %>();
            if(id == null){
                alert("No item was selected!");
                return false;
            }
            var returnValue = window.showModalDialog('<%=GetAddServicePageLink() %>' + '&mode=edit&id=' + id, '', 'dialogWidth=450px;dialogHeight=420px;resizable=no;help=no;unadorned=yes;');
            return returnValue > 0;
        }
        
        function showNetwork(){
            var returnValue = window.showModalDialog('EditPages/NetworkList.aspx', '', 'dialogWidth=800px;dialogHeight=450px;resizable=no;help=no;unadorned=yes;');
        }
        
        function showCurrentContracts(){
            var returnValue = window.showModalDialog('EditPages/ViewContracts.aspx', '', 'dialogWidth=900px;dialogHeight=600px;resizable=no;help=no;unadorned=yes;');
        }

        function focusIMEI(){
            document.getElementById('<%= txtIMEI.ClientID %>').focus();
        }
    </script>

    <uc:PageHeader ID="pageHeader" Text="Contracts" ImageURL="~/Images/contract.png"
        runat="server" />
    <table width="100%">
        <tr>
            <td style="text-align: left; vertical-align: top">
                <asp:UpdatePanel UpdateMode="Conditional" ID="updatePanelLeft" runat="server">
                    <ContentTemplate>
                        <asp:Panel ID="panelLeft" runat="server" class="primaryPanel">
                            <div class="titleBar">
                                <asp:Label ID="Label4" runat="server" CssClass="titleContent">Add Contract</asp:Label>
                            </div>
                            <div class="primaryFrameNoBorder">
                                <asp:UpdatePanel UpdateMode="Conditional" ID="UpdatePanel4" runat="server">
                                    <ContentTemplate>
                                        &nbsp;&nbsp;&nbsp;<asp:Label ID="label5" runat="server" Text="Customer:" class="labelMessage"></asp:Label>
                                        <cc1:ComboBox ID="ddlCustomer" runat="server" AutoCompleteMode="Suggest" AutoPostBack="true"
                                            CssClass="WindowsStyle" DropDownStyle="Simple" AppendDataBoundItems="true" OnSelectedIndexChanged="ddlCustomer_OnSelectedIndexChanged"
                                            OnItemInserted="ddlCustomer_OnItemInserted" Width="200px">
                                        </cc1:ComboBox>
                                        &nbsp;
                                        <asp:Label ID="lblCustPrice" runat="server" Font-Size="16px" Font-Bold="true" CssClass="lblClass"></asp:Label>
                                        &nbsp;&nbsp;&nbsp;<asp:Label class="labelNote" ID="labelHint" runat="server">(*) Type a name</asp:Label>
                                        <div style="height: 5px">
                                            &nbsp;</div>
                                    </ContentTemplate>
                                </asp:UpdatePanel>
                                <%--<asp:UpdatePanel UpdateMode="Conditional" ID="updateLeft" runat="server">
                                    <ContentTemplate>--%>
                                <table width="100%" class="toolbar">
                                    <tr>
                                        <td style='vertical-align: middle'>
                                            <asp:LinkButton class="tbbutton" ID="btnAddService" runat="server" OnClientClick=" return onAddService();"
                                                OnClick="btnAddService_Click">
                                                <asp:Image ID="image2" runat="server" ImageUrl="~/Images/Network-Service-icon.png" /><asp:Label
                                                    ID="label12" runat="server" Text="Add Service"></asp:Label>
                                            </asp:LinkButton>
                                            <asp:LinkButton class="tbbutton" ID="btnDeleteProd" runat="server" OnClientClick="return onRemoveContract();"
                                                OnClick="btnRemoveContract_Click">
                                                <asp:Image ID="image3" runat="server" ImageUrl="~/Images/Delete.gif" /><asp:Label
                                                    ID="label13" runat="server" Text="Delete"></asp:Label>
                                            </asp:LinkButton>
                                        </td>
                                    </tr>
                                </table>
                                <asp:UpdatePanel UpdateMode="Conditional" ID="updateGrid" runat="server">
                                    <ContentTemplate>
                                        <asp:Panel ID="panelGrid" runat="server">
                                            <uc:AddContract ID="addContract" runat="server" AllowPaging="false" AllowSorting="false"
                                                AllowSelecting="true" SaveOnCommit="false" Width="100%" />
                                            <asp:Button ID="btnAddIMEI" runat="server" Style="display: none" OnClick="btnAddIMEI_OnClick" />
                                            <center>
                                                <div style="height: 15px">
                                                    &nbsp;</div>
                                                <asp:Button ID="btnNew" runat="server" Text="Clear All" OnClick="btnNew_OnClick" />
                                                <asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_OnClick" />
                                            </center>
                                            <div style="height: 5px">
                                                &nbsp;</div>
                                        </asp:Panel>
                                    </ContentTemplate>
                                </asp:UpdatePanel>
                            </div>
                            <%-- </ContentTemplate>
                                </asp:UpdatePanel>--%>
                            </div>
                        </asp:Panel>
                    </ContentTemplate>
                </asp:UpdatePanel>
            </td>
            <td style="width: 200px; text-align: left; vertical-align: top">
                <asp:UpdatePanel UpdateMode="Conditional" ID="UpdatePanel3" runat="server">
                    <ContentTemplate>
                        <asp:Panel ID="panel1" runat="server" class="primaryPanel">
                            <div class="titleBar">
                                <asp:Label ID="Label1" runat="server" CssClass="titleContent">Contract Manager</asp:Label>
                            </div>
                            <div class="primaryFrameNoBorder">
                                <asp:UpdatePanel UpdateMode="Conditional" ID="updateIMEI" runat="server">
                                    <ContentTemplate>
                                        <asp:Panel ID="panelIMEI" runat="server" DefaultButton="btnAddIMEI" >
                                            <asp:TextBox ID="txtIMEI" runat="server" Width="195px" onfocus="this.select();" ></asp:TextBox>
                                        </asp:Panel>
                                    </ContentTemplate>
                                </asp:UpdatePanel>
                                <asp:Label class="labelNote" Text="(*) Scan and press Enter." runat="server"
                                    ID="label6"></asp:Label>
                                <div style="height: 20px">
                                    &nbsp;</div>
                                <asp:Button ID="btnNetWorks" runat="server" OnClientClick="showNetwork(); return false;" Text="Network List"
                                    Width="100%" />
                                <div style="height: 4px">
                                    &nbsp;</div>
                                <asp:Button ID="btnCurrentContract" runat="server" OnClientClick="showCurrentContracts();return false;"
                                    Text="Current Contracts" Width="100%" />
                                
                            </div>
                        </asp:Panel>
                    </ContentTemplate>
                </asp:UpdatePanel>
            </td>
        </tr>
    </table>
</asp:Content>
